package org.sws.domain.strategy.service.rule.chain.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.sws.domain.strategy.enums.LogicModel;
import org.sws.domain.strategy.model.valobj.ChainStrategyAwardVO;
import org.sws.domain.strategy.service.armory.IStrategyDispatch;
import org.sws.domain.strategy.service.rule.chain.AbstractLogicChain;

import javax.annotation.Resource;

/**
 * @Author sws
 * @Date 2025/2/24 16:11
 * @description: 默认兜底责任链节点
 */
@Slf4j
@Service("rule_default")
public class DefaultLogicChain extends AbstractLogicChain {

    @Resource
    protected IStrategyDispatch strategyDispatch;
    @Override
    protected String ruleModel() {
        return LogicModel.RULE_DEFAULT.getCode();
    }

    @Override
    public ChainStrategyAwardVO logic(String userId, Long strategyId) {
        Integer awardId = strategyDispatch.getRandomAwardId(strategyId);
        log.info("抽奖责任链-默认处理 userId: {} strategyId: {} ruleModel: {} awardId: {}", userId, strategyId, ruleModel(), awardId);
        return ChainStrategyAwardVO.builder().logicModel(ruleModel()).awardId(awardId).build();
    }
}
